<?php

namespace Account\Model;

use Common\Model\BaseModel;
use Common\Model\ModelException;
use Util\StringUtils;
use Carbon\Carbon;

class ClinichistoryModel extends BaseModel
{
    protected $_auto = [
        ['create_time', 'time', self::MODEL_INSERT, 'function'],
        ['content', 'serialize', self::MODEL_BOTH, 'function'],
    ];

    protected $_validate = [
        ['user_id', 'require', '用户不能为空'],
        // ['content', 'require', '内容不能为空', self::MUST_VALIDATE],
    ];

    protected $_scope = [
        'valid' => [
            'where' => [
                'delete_time' => 0,
            ]
        ]
    ];

    protected function _after_find(&$record, $options)
    {
        if ($record['content']) $record['content'] = unserialize($record['content']);
    }

    protected function _after_select(&$records, $options)
    {
        foreach ($records as &$record) {
            $this->_after_find($record, $options);
        }
    }
    
}
